# DarkCube X-8 Skin Sheet

import logwriter
from configobj import ConfigObj

class skin_version:
    def __init__(self):
        return 1.0
    
class sheet:
    def __init__(self):
        log = logwriter.writer('skin.py')
        log.status('Skin Sheet started')
        filename='skinset.ini'
        log.status('Reading from '+filename)
        self.data = ConfigObj(filename)
        log.status('Reading successful')
        datatype = {
            'property':{
                'name':'string',
                'version':'float',
                'author':'string'
            },
            'window':{
                'width':'integer',
                'height':'integer',
                'theight':'integer',
                'background':'string'
            },
            'timing':{
                'x':'integer',
                'y':'integer',
                'size':'integer',
                'fface':'string',
                'color':'string'
            }            
        }
        for section in self.data:
            for key in self.data[section]:
                self.data[section][key]=self.casttype(self.data[section][key],datatype[section][key])
    def getdata(self):
        return self.data
    def casttype(self,strInput,strType):
        if strType=='string':
            return str(strInput)
        elif strType=='integer':
            return int(strInput)
        elif strType=='float':
            return float(strInput)
        else:
            return strInput
    
if __name__=='__main__':
    print ' Skin Sheet cannot run individually '
